package fanxinlianxi;

import java.util.ArrayList;

public class FanXin06 {
    public static void main(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        ArrayList<Number> arrayList2 = new ArrayList<>();
        ArrayList<Object> arrayList3 = new ArrayList<>();
        print(arrayList);
        print(arrayList1);
        method1(arrayList1);//Number和Number的所有子类
        method1(arrayList2);//Number和Number自己的所有子类
        //method1(arrayList3);//Number和Number的所有父类
        method2(arrayList3);//Number和Number的所有父类
        method2(arrayList2);//Number和Number自己
        //method2(arrayList1);//Number和Number的所有子类
    }

    //泛型通配符可表现范围
    //? extends Number 规定了上边界，Number和Number的所有子类，最多不能超过Number这个类
    //?  super Number 规定了下边界，Number和Number的所有父类
    public static void print(ArrayList<?> list) {
    }

    public static void method1(ArrayList<? extends Number> list) {
    }

    public static void method2(ArrayList<? super Number> list) {
    }
}
